package com.atguigu.juc.one;

public class ThreadDemo {
    public static void main(String[] args) {
        //多线程,
        // 方式1
        Thread thread1 = new Thread(
                new Runnable() {
                    @Override
                    public void run() {
                        System.out.println("1:"+ Thread.currentThread().getName());
                    }
                }
        );
        thread1.start();

        //方式2
        MyThread myThread = new MyThread();
        myThread.start();

        //方式3
        MyRunnable myRunnable = new MyRunnable();
        new Thread(myRunnable).start();

        //TODO 方式4，线程池, JUC下

        //5.lambdas
        new Thread(()->{
            System.out.println("5:" + Thread.currentThread().getName());
        }).start();
    }
}

//方式2，先创建该类
class MyThread extends Thread{
    @Override
    public void run() {
        System.out.println("2:" + Thread.currentThread().getName());
    }
}

//方式3，先创建该类
class MyRunnable implements Runnable{
    @Override
    public void run() {
        System.out.println("3:" + Thread.currentThread().getName());
    }
}